﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Project Management System</title>
     <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
     @*END SignalR*@
    <script src="@Url.Content("~/Scripts/jquery.signalR-0.5.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/knockout-2.1.0.js")" type="text/javascript"></script>
    <script  src="@Url.Content("/signalr/hubs")" type="text/javascript"></script>
    <script  src="@Url.Content("~/Scripts/chatR.js")" type="text/javascript"></script>
    @*END SignalR*@
    <script src="../../Scripts/modernizr-1.7.js" type="text/javascript"></script>
    <link rel="stylesheet" href="../../Content/reset.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../Content/style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../Content/invalid.css" type="text/css" media="screen" />
    <link href="../../Scripts/jquery-ui-1.8.20.custom.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/simpla.jquery.configuration.js"></script>
    <script type="text/javascript" src="../../Scripts/facebox.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.wysiwyg.js"></script>
   @* <script type="text/javascript" src="../../Scripts/jquery.datePicker.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.date.js"></script>*@
    <script src="../../Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../Scripts/PMS.js" type="text/javascript"></script>
    <script src="../../Scripts/PMS.lang.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.alerts.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/fileuploader.js" type="text/javascript"></script>
    <link href="../../Scripts/fileuploader.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery.fn.gantt.js" type="text/javascript"></script>
    <link href="../../Content/gantt.css" rel="stylesheet" type="text/css" />
   
</head>
<body>
    <div id="body-wrapper">
        <!-- Wrapper for the radial gradient background -->
        <div id="sidebar">
            <div id="sidebar-wrapper">
                <!-- Sidebar with logo and menu -->
                <h1 id="sidebar-title">
                    <a href="#">Simpla Admin</a></h1>
                <!-- Logo (221px wide) -->
                <a href="#">
                    <img id="logo" src="../../Content/images/logo.png" alt="Simpla Admin logo" /></a>
                <!-- Sidebar Profile links -->
                <div id="profile-links">
                    Hello, <a href="#" title="Edit your profile">@PMS.Utilities.Utility.UserName</a>
                    <input id="UserID" value="@PMS.Utilities.Utility.UserID" type="hidden" />
                    <br />
                    <a id="asignout" style="cursor: pointer" title="Sign Out">Sign Out</a>
                </div>
                <ul id="main-nav">
                    <!-- Accordion Menu -->
                    <li><a id="Dashboard" href="@Url.Action("Dashboard", "Home")" class="nav-top-item no-submenu" >
                        Notification
                        <!-- Add the class "no-submenu" to menu items with no sub menu -->
                        <span id="sNotification" style="color: Red"></span></a></li>
                    <li><a id="Project" href="#" class="nav-top-item ">
                        <!-- Add the class "current" to current menu item -->
                        Project </a>
                        <ul>
                            <li><a id="MProject" href="@Url.Action("ManageProject", "Project")">Manage Project</a></li>
                            <li><a id="AcProject" href="@Url.Action("ActiveProject", "Project")">Active Project</a></li>
                            <li><a id="Group"href="@Url.Action("ManageGroup", "Project")">Manage Group</a></li>
                            <!-- Add class "current" to sub menu items also -->
                        </ul>
                    </li>
                    <li><a id="Schedule" href="#" class="nav-top-item">Schedule</a>
                        <ul>
                            <li><a id="MSchedule" href="@Url.Action("ManageSchedule", "Schedule")">Manage Schedule</a></li>
                            <li><a id="Progress" href="@Url.Action("ManageProgress", "Schedule")">Manage Progress</a></li>
                        </ul>
                    </li>
                    @{if (PMS.Utilities.Utility.RoleID != 3)
                      {
                        <li><a id="Report" href="#" class="nav-top-item">Report</a>
                            <ul>
                                <li><a id="PReport" href="@Url.Action("ProjectReport", "Report")">Project Report</a></li>
                                <li><a id="PSReport" href="@Url.Action("StudentProjectReport", "Report")">Project-Student
                                    Report</a></li>
                                <li><a id="StReport" href="@Url.Action("StudentReport", "Report")">Student Report</a></li>
                                <li><a id="SReport" href="@Url.Action("ScheduleReport", "Report")">Schedule Report</a></li>
                            </ul>
                        </li>
                      }
                    }
                    <li><a id="Referecent" href="#" class="nav-top-item">Reference</a>
                        <ul>
                            <li><a id="Reference" href="@Url.Action("ManageReference", "Reference")">Reference</a></li>
                        </ul>
                    </li>
                    <li><a id="Setting" href="#" class="nav-top-item">Setting</a>
                        <ul>
                            @{if (PMS.Utilities.Utility.RoleID == 1)
                              {
                                <li><a id="ManageSemester" href="@Url.Action("ManageSemester", "Setting")">Manage Semester</a></li>
                                <li><a id="ManageDepartment" href="@Url.Action("ManageDepartment", "Setting")">Manage
                                    Department</a></li>
                                <li><a id="ManageSubject" href="@Url.Action("ManageSubject", "Setting")">Manage Subject</a></li>
                                <li><a id="ManageUser" href="@Url.Action("ManageUser", "Setting")">Manage User</a></li>
                              }
                            }
                            <li><a id="AccountInfo" href="@Url.Action("AccountInfo", "Setting")">Account Info</a></li>
                            @{if (PMS.Utilities.Utility.RoleID != 3)
                              {
                                <li><a id="ChangePassword" href="@Url.Action("ChangePassword", "Setting")">Change Password</a></li>
                              }
                            }
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <!-- End #sidebar -->
        <div id="main-content">
            <!-- Main Content Section with everything -->
            <noscript>
                <!-- Show a notification if the user has disabled javascript -->
                <div class="notification error png_bg">
                    <div>
                        Javascript is disabled or is not supported by your browser. Please <a href="http://browsehappy.com/"
                            title="Upgrade to a better browser">upgrade</a> your browser or <a href="http://www.google.com/support/bin/answer.py?answer=23852"
                                title="Enable Javascript in your browser">enable</a> Javascript to navigate
                        the interface properly.
                    </div>
                </div>
            </noscript>
            @RenderBody()
            <div id="footer">
                <small>
                    <!-- Remove this notice or replace it with whatever you want -->
                    &#169; Copyright 2012 K Team | Powered by K Team | Themes by Simpla Admin</small>
            </div>
            <!-- End #footer -->
        </div>
        <!-- End #main-content -->
        <iframe id="myIFrame" src="" style='display: none;'></iframe>
        <ul id="messages">
        </ul>
        <div id="Notifications">
        </div>
    </div>
    @{if (TempData["Message"] != null)
      {
        <script type="text/javascript">

            var message = '@TempData["Message"]';
            if (message != '') {
                if (message.indexOf('Error') >= 0) {
                    $('.notification').addClass('error');
                }
                else if (message.indexOf('Attention') >= 0) {
                    $('.notification').addClass('attention');
                }
                else if (message.indexOf('Success') >= 0) {
                    $('.notification').addClass('success');
                }
                else if (message.indexOf('Infomation') >= 0) {
                    $('.notification').addClass('information');
                }
            }
        </script>
      }
    }
    <script type="text/javascript">
        $("#asignout").click(function () {
            $('#myIFrame').attr('src', 'https://www.google.com/accounts/Logout');
            $.post('@Url.Action("SignOut", "Home")');
            window.location.href = "/";
        });


        //Global variables
        var DateTimeFormat = '@PMS.Utilities.Utility.DateTimeFormat';
        //Notification
        function GetNotification() {
            var userID = $('#UserID').val();
            $.post('@Url.Action("GetNotification", "Home")', { UserID: userID }, function (data) {
                if (isNaN(data)) {
                    window.location.href = "/";
                }
                else {
                    if (data != '0') {
                        $("#sNotification").text('(' + data + ')');
                    }
                }
            });
        }
        GetNotification();

        var users = new chatR.connectedUsersViewModel();
        var currentUser = new chatR.user(@Html.Raw(Json.Encode(PMS.Utilities.Utility.UserID.ToString()))); // The userid choose by the user is stored in the model

        // Proxy creation
        var chatHub = $.connection.chatHub; // chatHub is the name of the Hub as declared in server side code
        chatHub.userid = currentUser.userid; // This is the round-trip state
        // Client-side event handlers, as declared inside the  Hub
        chatHub.onMessageReceived = function (message) {
             var closebtn = "<div class=\"btnClose\">X</div>";
	         var text = "<div class=\"text\">" + message + "</div>";
	         $('#Notifications').append('<div class=\"notify\">' + closebtn + text + '</div>');
	         $(".notify").show(200);
             GetNotification();
        }
        
        chatHub.leaves = function (connectionId, userid, timestamp) {
            var disconnectedUser = new chatR.user(userid, connectionId);
            users.customRemove(disconnectedUser);
        }

        chatHub.joins = function (connectionId, userid, timestamp) {
            var connectedUser = new chatR.user(userid, connectionId);
            users.contacts.push(connectedUser);
        }
         $('.btnClose').live("click", function (e) {
	                    $(this).parent().remove();
	                });

        // Step 1: Start the connection
        // Step 2: Get all currenlty connected users
        // Step 3: Join to the chat and nmotify all the clients (me included) that there is a new user connected
        $.connection.hub.start()
                    .done(function () {
                        chatHub.getConnectedUsers()
                                    .done(function (connectedUsers) {
                                        ko.utils.arrayForEach(connectedUsers, function (item) {
                                            users.contacts.push(new chatR.user(item.userid, item.Id));
                                        });
                                    }).done(function () {
                                        chatHub.joined();
                                    });
                    });
   

</script>
</body>
</html>
